<template>
    <div style="width:100%;height:100%;overflow: hidden;">
     <div id="main-map">
     </div>
    </div>
</template>
<script>
import imag from '../../src/assets/timg.gif'
export default {
    data () {
        return {
         map:null,
         context:null,
         data :null,
        }
    },
    mounted() {
        this.init()
    },
    methods:{
        init(){
          this.smartmapx.mapbase = 'http://www.smartmapx.com';
          this.smartmapx.apikey = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJuYmYiOjE1MzcxODM1OTgsImRhdGEiOiJ7XCJsb2dpbl9uYW1lXCI6XCJyb290XCIsXCJnZW5kZXJcIjoyLFwidXNlcl9pZFwiOlwiZm1fc3lzdGVtX3VzZXJfcm9vdFwiLFwidXNlcl9uYW1lXCI6XCJyb290XCIsXCJ1c2VyX29yaWdpbl9pZFwiOlwiZm1fbG9jYWxcIixcInByb2R1Y3RfaWRcIjpcIlwiLFwiZXhwaXJlX3RpbWVcIjpcIlwiLFwic291cmNlX2lkXCI6XCJcIixcInR5cGVcIjpcIlwiLFwiY29ycF9pZFwiOlwiZm1fc3lzdGVtX2NvcnBcIn0iLCJleHAiOjQwOTI1OTkzNDksImp0aSI6ImFfNjhmZjBhZGY5OTcxNDQ0NThjNzViZWFiN2FjNTkzYWYifQ.W122WkT6QR4HZWbpalkpmirV9JWkDYcCkmNZoxCB_z8';
          this.map=new this.smartmapx.Map({
              container: 'main-map',
              mapId: 'map_id_1',
              center: [116.39738, 39.90579],
              zoom: 12.4
            });
            this.map.addControl(new this.smartmapx.NavigationControl(),'top-right');
            this.map.addControl(new this.smartmapx.ScaleControl({
              maxWidth: 100,
              unit: 'm'
            }));
           
            this.map.on('load',() =>{
               this.map.addLayer({
                "id": "route",
                "type": "line",
                "source": {
                "type": "geojson",
                "data": {
                "type": "Feature",
                "properties": {},
                "geometry": {
                "type": "LineString",
                "coordinates": [
                [116.35609543885926,39.908950283045186],
                [116.38956940736557,39.888405837288644],
                [116.42733491028844,39.908160225942964],
                [116.44467270936565,39.9280405586465]
                ]
                }
                }
                },
                "layout": {
                "line-join": "round",
                "line-cap": "round"
                },
                "paint": {
                "line-color": "red",
                "line-width": 8
                }
             });
          });
        }
    }
}
</script>
<style lang="scss" scoped>
#main-map{
    width: 100%;
    height: 100%;
}

</style>